﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestPlatform.Core;
using MongoDB.Driver;
using MongoDB.Bson;
using TestPlatform.Performer.MongoDB.Entities;

namespace TestPlatform.Performer.MongoDB
{
    public class MongoDBInsertPerformer : BaseInsertPerformer
    {
        public override string UnderlyinEngine { get { return "MongoDB"; } }

        public MongoDBInsertPerformer()
            : base(new MongoDBHelper())
        {

        }

        protected override void InsertEntity()
        {            
            var collection = MongoDBHelper.GetDatabase().GetCollection<User>("Users");

            collection.Insert(new User
            {
                Id = Guid.NewGuid(),
                Login = Guid.NewGuid().ToString(),
                Name = Guid.NewGuid().ToString(),
                Posts = Enumerable.Range(0, TestConfig.InsertSubEntitiesCount)
                    .Select(i => new Post { Id = Guid.NewGuid(), Text = Guid.NewGuid().ToString() })
                    .ToList()
            });

        }
    }
}
